<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="Admin/webroot/css/style.css"/>
<title>添加规则</title>
</head>
<script type="text/javascript" src="Admin/webroot/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="Admin/webroot/js/global.js"></script>
<script type="text/javascript" src="Admin/webroot/js/input.js"></script>
{if $action=='create_rule'}
<script>
 $(function(){ 
sessionStorage.removeItem('wxnewsdata');
                		//新建的清空一下
					//sessionStorage.setItem("wxnewsdata", '');
 })
</script>
{/if}
<script type="text/javascript" src="Admin/webroot/js/weixin.js"></script>

<style>td .ke-inline-block{ display:none} </style>
<!--[if IE ]>
<style>.localUpload{ display:none}td .ke-inline-block{ display:block} </style>
<![endif]-->
<body>
<!--[if lte IE 6]>
<script src="js/DD_belatedPNG_0.0.8a.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
	DD_belatedPNG.fix('.pngfix');
</script>
<![endif]-->
<div class="rightbox">
    	<div class="rightbox-col" id="rightbox">
        	<div class="main">
                {include file='../Common/main_title.html'}
                <div class="bd">
                	<div class="height_20"></div>
                    <div class="menu-add">
                    	<div class="hd">
                        	<table>
                            	<tr>
                                	<td width="85px" style="padding-right:7px" align="right">消息类型：</td>
                                    <td width="434px">
                                
                                     <a data-name='type'  data-value="1"  {if $rule.type}{if $rule.type eq 1}class="focus"{else}class="selectBtn"{/if}{else}class="tabBtn selectBtn focus"{/if} href="javascript:;"> 文字</a>
                                            <a data-name='type' data-value="2"    {if $rule.type}{if $rule.type eq 2}class="focus"{else}class="selectBtn"{/if}{else}class="tabBtn selectBtn"{/if}   href="javascript:;">图文</a>
                                          
                                
                                          <input type="hidden" name="type"  value="{if $rule.type}{$rule.type}{else}1{/if}"/>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="bd">
                        	
							<table cellpadding="0" cellspacing="0" width="100%" border="0">
                                    
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right"><span class="red">*</span>规则标题：</td>
                                        
                                        <td width="434px">
                                        	<div class="s-select-c">
                                        		<input type="text" name="name" value="{$rule.name}"/>
                                                

                                            </div>
                                            
                                        </td>
                                        <td></td>
                                    </tr>
                                    {if $action=='create_rule'}
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">关键词：</td>
                                        
                                        <td width="434px">
                                        	<div class="s-select-c">
                                        		<input type="text" placehod="选填" name="keyword" />
                                                

                                            </div>
                                            
                                        </td>
                                        <td></td>
                                    </tr>
                                    {/if}
                                    <tr id="type1" {if $rule.type}{if $rule.type eq 1}style=""{else}style="display:none;"{/if}{else}style=""{/if}>
                                        <td width="85px" style="padding-right:7px" align="right">文字内容：</td>
                                        <td width="434px"><textarea class="keywords" name="content">{$rule.content}</textarea></td>
                                        <td></td>
                                    </tr>
                                    <tr id="type2" {if $rule.type eq 2}style=""{else} style="display:none"{/if}>
                                    <td colspan="3" style="padding-bottom: 0px;">
                                    <table>
                                    <tr class="wxnews_crtl">
                                    <td width="85px"></td>
                                        <td align="left">
                                        {if $rule.pic_num}
                                        {section name=pic loop=$rule.pic_num}


                                   
                                            <a class="wxnews {if $smarty.section.pic.iteration eq 1}select_news{/if}" news_id='{$smarty.section.pic.iteration}' href="javascript:void(0)">图文{$smarty.section.pic.iteration}</a>
                                            {/section}
                                        {else}
                                        <a class="wxnews select_news" news_id='1' href="javascript:void(0)">图文1</a>
                                        {/if}
                                        <a title="添加图文" class="add_wxnews" href="javascript:void(0)">[+]</a>
                                        <a title="删减图文" class="cut_wxnews" href="javascript:void(0)">[-]</a>
                                        </td>
                                        
                                        <td></td>
                                    </tr>
                                    
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">图文标题：</td>
                                        <td width="434px"><input type="text" name="news_title" value="{$menu.keywords}"/> <input type="hidden" name="news_id"  value=""/></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">图文描述：</td>
                                        <td width="434px"><input type="text" name="news_des" value="{$menu.description}"/></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">图文链接：</td>
                                        <td width="434px"><input type="text" name="news_url" value="{$menu.news_url}"/></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                      <td width="85px" style="padding-right:7px" align="right">关联本站：</td>
                                       <td width="434px">
                                       <div class="s-select-c" style="z-index:999;">
                                        		<input type="text" autocomplete="off" name="parent_name" {if $art.rule_name}value="{$art.rule_name}"{else}value="请选择关联文章"{/if} class="s-select"/>
                                                <div class="s-select-menu" id="s1" style="z-index:999">
                                                	<ul>
           {foreach from=$art_list item=list}                                          	<li data-select="{$list.id}"><a onclick="creareLink({$list.id})" href="#">{$list.title}</a></li>
                                                        {/foreach}                                                </ul>
                                                </div>
                                                <input type="hidden" class="fmenu" name="rule_id" value="{$art.rid}" />
                                            </div>
                                       
                                       </td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">缩略图：</td>
                                        <td width="434px"><input type="text" id="url" readonly="readonly" name="thumb_url" value="{$menu.thumb}" id="thumb"/>
                                       
                                        </td>
                                        <td>
                                        	<a href="javascript:;"   class="localUpload" onclick="$('input[name=thumb]').click()">本地上传</a>
                                             {if $menu.thumb}
                                        <img style="position: absolute;
margin-top: 10px;" src="{$menu.thumb}" width="80px" />
                                        {/if}
                   <input id="uploadButton" type="button" value="submit" />                        
                                           
                                        </td>
                                    </tr>
                                    </table>
                                    </td>
                                    </tr>
                                    
                                </table>
                                <div class="height_24"></div>
                                <div class="pro-add-sub-c">
                                <input type="hidden" name="id" class="show" value="{$rule.id}"/>
                                
                                <input type="submit" class="submit_btn pro-add-sub" style="width:86px; height:31px; border:none;" value="提交"/></div>
                              
                        </div>
                        
                        
                    </div>
                </div>
                 
                {if $rule.pic_img}
                <script>
                $(function(){
                		
					sessionStorage.setItem("wxnewsdata", '{$rule.pic_img}');
                	var msg = sessionStorage.getItem("wxnewsdata");
		var session = new Object();
		if (msg != null&&msg!='') {
			session = JSON.parse(msg);

					if (typeof(session[1]) != 'undefined') {
			$('#type2 input[name=news_title]').val(session[1].news_title);
			$('#type2 input[name=news_id]').val(session[1].news_id);

			$('#type2 input[name=news_des]').val(session[1].news_des);
			$('#type2 input[name=news_url]').val(session[1].news_url);
			$('#type2 input[name=thumb_url]').val(session[1].thumb_url);
		}
				}
					})
                </script>
                {/if}
            </div>
        </div>
        <div class="clear"></div>
    </div>
<script type="text/javascript" src="Admin/webroot/js/editor/kindeditor.js"></script>
<script type="text/javascript">
    $(function(){
		$('.pro-add-sub').click(function(){
			var action = '{$action}';
		    var id=($('input[name=id]').val());
			var name=($('input[name=name]').val());
			var content=($('textarea[name=content]').val());
			var type=($('input[name=type]').val());
			var news_title=($('input[name=news_title]').val());
			var news_des=($('input[name=news_des]').val());
			var news_url=($('input[name=news_url]').val());
			if(action=='create_rule')
			{
			var keyword=($('input[name=keyword]').val());
			}
			else
			{
				var keyword='';
			}
			
		    var thumb_url=($('input[name=thumb_url]').val());
			var news = sessionStorage.getItem("wxnewsdata");
			$.post('index.php?g=admin&m=wxrule&a='+action,{ id:id,keyword:keyword,type:type,content:content,name:name,news:news,thumb_url:thumb_url},function(result){
			//alert(result);
			//console.log(result);
			if(result.error==0)
			{
			sessionStorage.removeItem('wxnewsdata');
				
			}
			
			showMsg(result.content,result.url);	
			//window.history.go(0);
				},'json');
			})
		
		});
	KindEditor.ready(function(K) {
     window.editor = K.create('#pro-view');
	 
	 var uploadbutton = K.uploadbutton({
					button : K('#uploadButton')[0],
					fieldName : 'thumb',
					url : 'index.php?g=admin&m=wxrule&a=file',
					afterUpload : function(data) {
						if (data.error === 0) {
							var url = K.formatUrl(data.url, 'absolute');
							K('#url').val(url);
							set_session();
						} else {
							alert(data.message);
						}
					},
					afterError : function(str) {
						alert('自定义错误信息: ' + str);
					}
				});
				uploadbutton.fileBox.change(function(e) {
					uploadbutton.submit();
					
				});
	 
});
</script>

</body>
</html>
